package jianzhioffer.tree;

import algorithm.model.TreeNode;

/**
 * 二叉树的镜像
 * Created by yzy on 2020-05-28 19:37
 */
public class MirrorTree {

    public static void main(String[] args) {
        TreeNode node = TreeNode.getTreeNode(new Integer[]{8,6,10,5,7,9,11});
        System.out.println(node);
        mirror(node);
        System.out.println(node);
    }

    public static void mirror(TreeNode root) {
        if(root==null){
            return;
        }
        TreeNode tmp = root.left;
        root.left = root.right;
        root.right = tmp;
        mirror(root.left);
        mirror(root.right);
    }

}
